from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class PlanterModel(BaseModel):
    """
    种植主体信息表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    planter_id: Optional[int] = Field(default=None, description='种植主体ID')
    year: Optional[int] = Field(default=datetime.today().year, description='数据年份')
    planter_name: Optional[str] = Field(default=None, description='主体名称')
    planter_type: Optional[str] = Field(default=None, description='主体类型')
    area_size_measured: Optional[float] = Field(default=0, description='实际量地面积')
    county: Optional[str] = Field(default=None, description='所在县')
    village: Optional[str] = Field(default=None, description='所在村')
    area_size_service: Optional[float] = Field(default=0, description='托管服务面积')
    measure_state: Optional[int] = Field(default=0, description='量地状态')
    sign_state: Optional[int] = Field(default=0, description='签约状态')
    is_rent: Optional[int] = Field(default=0, description='是否需要支付地租')
    principal: Optional[str] = Field(default=None, description='种植主体负责人')
    area_size_facility: Optional[float] = Field(default=0, description='签约设施种植面积（亩）')
    principal_mobile: Optional[str] = Field(default=None, description='负责人联系电话')
    principal_idno: Optional[str] = Field(default=None, description='负责人身份证号')
    is_seed: Optional[int] = Field(default=0, description='是否需要支付种苗款')
    seed_amount_estimated: Optional[float] = Field(default=0, description='种苗预估数量')
    area_size_openair: Optional[float] = Field(default=0, description='露地签约面积')
    taxer_no: Optional[str] = Field(default=None, description='纳税人识别号')
    bank_account_name: Optional[str] = Field(default=None, description='银行开户名称')
    remark: Optional[str] = Field(default=None, description='备注')
    area_size_policy: Optional[float] = Field(default=None, description='村集体流转面积')
    plant_density_openair: Optional[int] = Field(default=None, description='露地种植密度')
    plant_density_facility: Optional[int] = Field(default=None, description='设施种植密度')
    bank_account: Optional[str] = Field(default=None, description='银行账号')
    bank_name: Optional[str] = Field(default=None, description='开户银行')
    area_count_facility: Optional[int]=Field(default=0, description="签约设施种植棚数")
    create_by: Optional[str] = Field(default=None, description='创建者')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_by: Optional[str] = Field(default=None, description='更新者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')






class PlanterQueryModel(PlanterModel):
    """
    种植主体信息不分页查询模型
    """
    pass


@as_query
class PlanterPageQueryModel(PlanterQueryModel):
    """
    种植主体信息分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeletePlanterModel(BaseModel):
    """
    删除种植主体信息模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    planter_ids: str = Field(description='需要删除的种植主体ID')
